package com.flying.invest.stat.model;

import java.util.Date;

import com.flying.common.util.Codes;
import com.flying.framework.annotation.Param;
import com.flying.framework.annotation.ServiceField;
import com.flying.framework.annotation.ServiceFieldParam;
import com.flying.framework.data.Data;
import com.flying.framework.data.DataSerializable;
import com.flying.framework.metadata.Meta;
import com.flying.invest.invest.model.Investment;
import com.flying.invest.strategy.model.Strategy;

@SuppressWarnings("serial")
@Meta(id="i_strategy_stage_stat",title="阶段策略统计", table="i_strategy_stage_stat", primaryKeys={"stat_id"})
public class WaveStrategyStageStat extends Data implements DataSerializable {
	public final static String ENTITY_NAME = "i_strategy_stage_stat";
	
	public final static String STAT_ID = "stat_id";
	public final static String USER_ID = "user_id";
	public final static String INVEST_ID = "invest_id";
	public final static String TYPE_ID = "type_id";
	public final static String STRATEGY_ID = "strategy_id";
	public final static String DETAIL_ID = "detail_id";
	public final static String BUY_PRICE = "buy_price";
	public final static String BUY_AMOUNT = "buy_amount";
	public final static String BUY_QUANTITY = "buy_quantity";
	public final static String BUY_TRANSACTION_ID = "buy_transaction_id";
	public final static String BUY_TIME = "buy_time";

	public final static String PLAN_SELL_PRICE = "plan_sell_price";
	public final static String SELL_PRICE = "sell_price";
	public final static String SELL_AMOUNT = "sell_amount";
	public final static String SELL_QUANTITY = "sell_quantity";
	public final static String SELL_TRANSACTION_ID = "sell_transaction_id";
	public final static String SELL_TIME = "sell_time";
	public final static String PROFIT = "profit";
	
	
	@Param(value=STAT_ID, required=true, desc="ID" , generator=Codes.AUTO_INCREMENT)
	private Long statId;
	
	@Param(value=USER_ID, required=true, desc="所属用户" )
	private Long userId;
	
	@Param(value=INVEST_ID, required=true, desc="投资项目" )
	private Long investId;
	
	@Param(value=TYPE_ID, required=true, desc="策略类型" )
	private Long typeId;
	
	@Param(value=STRATEGY_ID, required=true, desc="策略ID" )
	private Long strategyId;
	
	@Param(value=DETAIL_ID, required=true, desc="明细ID" )
	private Long detailId;
	
	@Param(value=BUY_PRICE, required=true, desc="买入价格" )
	private Double buyPrice;
	
	@Param(value=BUY_AMOUNT, required=true, desc="买入金额" )
	private Double buyAmount;
	
	@Param(value=BUY_QUANTITY, required=false, desc="买入数量" )
	private Double buyQuantity;
	
	@Param(value=BUY_TRANSACTION_ID, required=true, desc="买入交易ID" )
	private Long buyTransactionId;
	
	@Param(value=BUY_TIME, required=false, desc="买入时间" )
	private Date buyTime;

	
	@Param(value=PLAN_SELL_PRICE, required=false, desc="计划卖出价格" )
	private Double planSellPrice;
	
	@Param(value=SELL_PRICE, required=false, desc="卖出价格" )
	private Double sellPrice;
	
	@Param(value=SELL_AMOUNT, required=false, desc="卖出金额" )
	private Double sellAmount;
	
	@Param(value=SELL_QUANTITY, required=false, desc="卖出数量" )
	private Double sellQuantity;
	
	@Param(value=SELL_TRANSACTION_ID, required=false, desc="卖出交易ID" )
	private Long sellTransactionId;
	
	@Param(value=SELL_TIME, required=false, desc="卖出时间" )
	private Date sellTime;
	
	@Param(value=PROFIT, required=false, desc="利差" )
	private Double profit;

	@ServiceField(serviceId="InvestmentService:findById", params={@ServiceFieldParam(param=Investment.INVEST_ID, value="$"+INVEST_ID)})
	@Param(value="invest",   required=false,	desc="投资", ignored=true)
	private Investment invest;

	@ServiceField(serviceId="StrategyService:findById", params={@ServiceFieldParam(param=Strategy.STRATEGY_ID, value="$"+STRATEGY_ID)})
	@Param(value="strategy",   required=false,	desc="策略", ignored=true)
	private Strategy strategy;
	
	
	public Long getStatId() {
		return this.statId;
	}
	
	public void setStatId(Long statId) {
		this.statId = statId;
	}
	
	public Long getUserId() {
		return this.userId;
	}
	
	public void setUserId(Long userId) {
		this.userId = userId;
	}
	
	public Long getInvestId() {
		return this.investId;
	}
	
	public void setInvestId(Long investId) {
		this.investId = investId;
	}
	
	public Long getTypeId() {
		return this.typeId;
	}
	
	public void setTypeId(Long typeId) {
		this.typeId = typeId;
	}
	
	public Long getStrategyId() {
		return this.strategyId;
	}
	
	public void setStrategyId(Long strategyId) {
		this.strategyId = strategyId;
	}
	
	public Long getDetailId() {
		return this.detailId;
	}
	
	public void setDetailId(Long detailId) {
		this.detailId = detailId;
	}
	
	public Double getBuyPrice() {
		return this.buyPrice;
	}
	
	public void setBuyPrice(Double buyPrice) {
		this.buyPrice = buyPrice;
	}
	
	public Double getBuyAmount() {
		return this.buyAmount;
	}
	
	public void setBuyAmount(Double buyAmount) {
		this.buyAmount = buyAmount;
	}
	
	public Double getBuyQuantity() {
		return this.buyQuantity;
	}
	
	public void setBuyQuantity(Double buyQuantity) {
		this.buyQuantity = buyQuantity;
	}
	
	public Long getBuyTransactionId() {
		return this.buyTransactionId;
	}
	
	public void setBuyTransactionId(Long buyTransactionId) {
		this.buyTransactionId = buyTransactionId;
	}
	
	public Date getBuyTime() {
		return this.buyTime;
	}
	
	public void setBuyTime(Date buyTime) {
		this.buyTime = buyTime;
	}
	
	public Double getPlanSellPrice() {
		return planSellPrice;
	}

	public void setPlanSellPrice(Double planSellPrice) {
		this.planSellPrice = planSellPrice;
	}

	public Double getSellPrice() {
		return this.sellPrice;
	}
	
	public void setSellPrice(Double sellPrice) {
		this.sellPrice = sellPrice;
	}
	
	public Double getSellAmount() {
		return this.sellAmount;
	}
	
	public void setSellAmount(Double sellAmount) {
		this.sellAmount = sellAmount;
	}
	
	public Double getSellQuantity() {
		return this.sellQuantity;
	}
	
	public void setSellQuantity(Double sellQuantity) {
		this.sellQuantity = sellQuantity;
	}
	
	public Long getSellTransactionId() {
		return this.sellTransactionId;
	}
	
	public void setSellTransactionId(Long sellTransactionId) {
		this.sellTransactionId = sellTransactionId;
	}
	
	public Date getSellTime() {
		return this.sellTime;
	}
	
	public void setSellTime(Date sellTime) {
		this.sellTime = sellTime;
	}
	
	public Double getProfit() {
		return this.profit;
	}
	
	public void setProfit(Double profit) {
		this.profit = profit;
	}

	
	public Investment getInvest() {
		return invest;
	}

	public String getInvestName() {
		var invest = this.getInvest();
		return invest == null? null: invest.getName();
	}

	public Double getPrice() {
		var invest = this.getInvest();
		return invest == null? null: invest.getPrice();
	}

	public Strategy getStrategy() {
		return strategy;
	}
	
	public String getStrategyType() {
		var strategy = this.getStrategy();
		return strategy == null?null: strategy.getStrategyTypeName();
	}

}